/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * <p>Project: jse2303 - MyWriter</p>
 * <p>Powered by webrx On 2023-07-26 11:39:22</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class MyWriter implements Runnable {
    private String msg;

    private Socket c;

    private PrintWriter out;

    public MyWriter() {
        //Coming in
    }

    public MyWriter(String msg, Socket c) {
        this.msg = msg;
        try {
            this.out = new PrintWriter(c.getOutputStream());
        } catch (Exception e) {
        }
        this.c = c;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Socket getC() {
        return c;
    }

    public void setC(Socket c) {
        this.c = c;
    }

    @Override
    public void run() {
        while (true) {
            Scanner sc = new Scanner(System.in);
            out.printf("[%s]:%s", this.msg, sc.nextLine() + "\r\n");
            out.flush();
        }
    }
}
